<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品价格记录列表</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.table td {
			vertical-align: middle;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			if('${type}'!=''){
				parent.mainFrame.location.reload();
				document.location="${ctx}/ivm/product/showMarketPrice?product.id=${product.id}"+"&type="+'${priceType}';
			}
			//加载处理level选择控制
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        //提交修改
        function submitForm(){
        	var priceType = $("input[id='priceType']").val();
        	$("input[id='type']").val(priceType);
        	top.$.jBox.defaults.top="28%";
        	top.$.jBox.confirm("确认要修改吗？",'系统提示',function(v,h,f){
				if(v=='ok'){
					$('#inputForm').submit();
				}
			},{buttonsFocus:1});
        }
	</script>
</head>
<body>
	<form:form id="inputForm" modelAttribute="product" action="${ctx}/ivm/product/changePrice" method="post">
		<tags:message content="${message}"/>
		<form:hidden path="id"/>
		<input type="hidden" id="type" name="type" value="1"/>
		<input type="hidden" id="priceType" name="priceType" value="${priceType }"/>
		<div style="margin:10px;">
			<div class="control-group">
				<label><span class="color-red font-size20">*</span>${priceType==1?'原价':priceType==2?'现价':'进价' }：</label>
				<c:if test="${priceType==1 }">
					<form:input path="originalPrice" htmlEscape="false" class="required number decimal input-small" style="margin-bottom: 0px;"/>&nbsp;元&nbsp;
				</c:if>
				<c:if test="${priceType==2 }">
					<form:input path="price" htmlEscape="false" class="required number decimal input-small" style="margin-bottom: 0px;"/>&nbsp;元&nbsp;
				</c:if>
				<c:if test="${priceType==3 }">
					<form:input path="tradePrice" htmlEscape="false" class="required number decimal input-small" style="margin-bottom: 0px;"/>&nbsp;元&nbsp;
				</c:if>
				<input class="btn btn-primary" type="button" onclick="submitForm()" value="确认修改"/>
			</div>
		</div>
	</form:form>
	<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
	<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	<div style="margin:10px;">
		<table id="contentTable" class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th>价格</th>
					<th>登记日期</th>
					<th>登记人</th>
				</tr>
			</thead>
			<tbody>
			<c:forEach items="${page.list}" var="detail">
				<tr>
					<td>${detail.price }元</td>
					<td><fmt:formatDate value="${detail.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td>${detail.createBy.name }</td>
				</tr>
			</c:forEach>
			</tbody>
		</table>
		<div class="pagination">${page}</div>
	</div>
</body>
</html>